<!doctype html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport"
          content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>props的基本使用</title>
</head>
<body>
<!--准备好一个容器-->
<div id="test">

</div>
<div id="test2">

</div>
<div id="test3">

</div>
</body>

<!--核心库引入顺序，必须先是核心库然后在引入dom库-->
<script src="../js/react.development.js" crossorigin></script>
<!--用于支持react操作dom-->
<script src="../js/react-dom.development.js" crossorigin></script>
<!--引入babel，用于将jsx转为js-->
<script src="../js/babel.min.js" crossorigin></script>
<script type="text/babel">
    //创建组件
    class Person extends React.Component {
        render() {
            let {name, age, sex} = this.props;
            return (
                <ul>
                    <li>姓名：{name}</li>
                    <li>性别：{age+1}</li>
                    <li>年龄：{sex}</li>
                </ul>
            )
        }
    }

    //2.渲染组件到页面
    ReactDOM.render(<Person name="Tom" age={19} />, document.getElementById('test'))
    ReactDOM.render(<Person name="julia" age={20} sex="女"/>, document.getElementById('test2'))
    const person = {name: 'tom', sex: '女', age: 23}
    //ReactDOM.render(<Person name={person.name} age={person.age} sex={person.age}/>, document.getElementById('test3'))
    ReactDOM.render(<Person {...person}/>, document.getElementById('test3'))
</script>
</html>